﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace ChanTai.WebApi.Data
{
    /// <summary>
    /// 扩展工具
    /// </summary>
    public static class ConvertTool
    {
        /// <summary>
        /// Json转对象
        /// </summary>
        /// <param name="sour"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T ToQ<T>(this string sour) where T : Result
        {
            try
            {
                return string.IsNullOrEmpty(sour) ? null : JsonConvert.DeserializeObject<T>(sour);
            }
            catch (Exception err)
            {
                return null;
            }
        }
    }
}
